<?php

class WinningLogTest extends BaseTest
{
    public function testInsert()
    {
        $class = new \Orm\WinningLog\WinningLogClass();
		$class['user_id'] = $this->testNum();
		$class['memo'] = $this->testStr();
		$class['coupon_type'] = $this->testNum();
		$class['coupon_id'] = $this->testNum();
		$class['coupon_code'] = $this->testStr();
		$class['coupon_type_name'] = $this->testStr();


        $class->insert();
        $result_class = new \Orm\WinningLog\WinningLogClass();
        $result_class->loadById($class['id']);

		$this->assertEquals($class['user_id'],$result_class['user_id']);
		$this->assertEquals($class['memo'],$result_class['memo']);
		$this->assertEquals($class['coupon_type'],$result_class['coupon_type']);
		$this->assertEquals($class['coupon_id'],$result_class['coupon_id']);
		$this->assertEquals($class['coupon_code'],$result_class['coupon_code']);
		$this->assertEquals($class['coupon_type_name'],$result_class['coupon_type_name']);

        return $result_class;
    }

    /**
     * @depends testInsert
     */
    public function testUpdate($class)
    {
		$class['user_id'] = $this->testNum();
		$class['memo'] = $this->testStr();
		$class['coupon_type'] = $this->testNum();
		$class['coupon_id'] = $this->testNum();
		$class['coupon_code'] = $this->testStr();
		$class['coupon_type_name'] = $this->testStr();


        $class->update();
        $result_class = new \Orm\WinningLog\WinningLogClass();
        $result_class->loadById($class['id']);

		$this->assertEquals($class['user_id'],$result_class['user_id']);
		$this->assertEquals($class['memo'],$result_class['memo']);
		$this->assertEquals($class['coupon_type'],$result_class['coupon_type']);
		$this->assertEquals($class['coupon_id'],$result_class['coupon_id']);
		$this->assertEquals($class['coupon_code'],$result_class['coupon_code']);
		$this->assertEquals($class['coupon_type_name'],$result_class['coupon_type_name']);

        return $result_class;
    }

    /**
     * @depends testUpdate
     */

    public function testDelete($class)
    {
        $class->delete($class['id']);

        $result_class = new \Orm\WinningLog\WinningLogClass();
        $result_class->loadById($class['id']);
        $this->assertEquals(1, $result_class['is_del']);
        return $result_class;
    }


    /**
     * @depends testInsert
     */
    public static function testClean($class)
    {
        if ($class['id']) {
            $class->realDelete($class['id']);
        }
    }
}